﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <ControlTemplate x:Key="TopMenu_TopItem" TargetType="{x:Type MenuItem}">
        <Border x:Name="border" Margin="0,0,10,0" >
            <StackPanel Orientation="Horizontal" Cursor="Hand" >
                <ContentPresenter ContentSource="Icon"/>
                <ContentPresenter ContentSource="Header" RecognizesAccessKey="True" HorizontalAlignment="Center">
                    <ContentPresenter.Resources>
                        <Style TargetType="{x:Type TextBlock}">
                            <Setter Property="FontSize" Value="{StaticResource NormalFontSize}"/>
                            <Setter Property="Foreground" Value="{StaticResource TopMenuBrush}"/>
                        </Style>
                    </ContentPresenter.Resources>
                </ContentPresenter>
            </StackPanel>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="border" Property="Opacity" Value="0.5"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>


    <Style TargetType="{x:Type MenuItem}">
        <Setter Property="Template" Value="{StaticResource TopMenu_TopItem}"/>
    </Style>

    <!-- TOOLBARS MENUS -->
    <ControlTemplate x:Key="ToolBarMenu_TopLevelItem" TargetType="{x:Type MenuItem}">
        <Border x:Name="border" Style="{StaticResource MouseOverBorder}" MinWidth="60" MaxWidth="70" >
            <Grid Cursor="Hand" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="38"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                <ContentPresenter Grid.Row="0" ContentSource="Icon" Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" />
                <ContentPresenter Grid.Row="1" ContentSource="Header" RecognizesAccessKey="True" HorizontalAlignment="Center" VerticalAlignment="Center">
                    <ContentPresenter.Resources>
                        <Style TargetType="{x:Type TextBlock}">
                            <Setter Property="TextAlignment" Value="Center"/>
                            <Setter Property="TextWrapping" Value="Wrap"/>
                            <Setter Property="FontSize" Value="{StaticResource SmallFontSize}"/>
                            <Setter Property="Foreground" Value="{StaticResource ToolBarItemBrush}"/>
                        </Style>
                    </ContentPresenter.Resources>
                </ContentPresenter>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="border" Property="Opacity" Value="0.5"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="ToolBarMenu_SubmenuItem" TargetType="{x:Type MenuItem}">
        <Border x:Name="border" Style="{StaticResource MouseOverBorder}" Margin="1" Cursor="Hand">
            <Grid Margin="2,2,20,2" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto" />
                    <ColumnDefinition Width="auto" />
                </Grid.ColumnDefinitions>
                <ContentPresenter Grid.Column="0" ContentSource="Icon" Margin="0,0,5,0" HorizontalAlignment="Center" VerticalAlignment="Center" />
                <ContentPresenter Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True" HorizontalAlignment="Left" VerticalAlignment="Center">
                    <ContentPresenter.Resources>
                    </ContentPresenter.Resources>
                </ContentPresenter>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="border" Property="Opacity" Value="0.5"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="ToolBarMenu_TopLevelHeader" TargetType="MenuItem">
        <Grid x:Name="grid">

            <Border x:Name="border" Style="{StaticResource MouseOverBorder}" MinWidth="60" MaxWidth="70" >
                <Grid Cursor="Hand" >
                    <Grid.RowDefinitions>
                        <RowDefinition Height="38"/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <ContentPresenter Grid.Row="0" ContentSource="Icon" Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" />
                    <ContentPresenter Grid.Row="1" ContentSource="Header" RecognizesAccessKey="True" HorizontalAlignment="Center" VerticalAlignment="Center">
                        <ContentPresenter.Resources>
                            <Style TargetType="{x:Type TextBlock}">
                                <Setter Property="TextAlignment" Value="Center"/>
                                <Setter Property="TextWrapping" Value="Wrap"/>
                                <Setter Property="FontSize" Value="{StaticResource SmallFontSize}"/>
                                <Setter Property="Foreground" Value="{StaticResource ToolBarItemBrush}"/>
                            </Style>
                        </ContentPresenter.Resources>
                    </ContentPresenter>
                </Grid>
            </Border>
            <Popup 
                                    Name="Popup"
                                    Placement="Bottom"                                    
                                    StaysOpen="True"               
                                    IsOpen="{TemplateBinding IsSubmenuOpen}"
                                    AllowsTransparency="True" 
                                    Focusable="False"
                                    PopupAnimation="Fade">
                <Border
                                        Margin="0,0,5,5"
                                        CornerRadius="5,5,5,5"
                                        Name="SubmenuBorder"                              
                                        Background="{StaticResource ToolBarMenuDropDownBackground}"
                                        BorderBrush="{StaticResource ToolBarMenuBorderBrush}"
                                        BorderThickness="2">
                    <StackPanel                                            
                                            IsItemsHost="True"
                                            KeyboardNavigation.DirectionalNavigation="Cycle" />
                    <Border.Effect>
                        <DropShadowEffect ShadowDepth="2" Opacity="0.5" />
                    </Border.Effect>
                </Border>
            </Popup>
        </Grid>

        <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="border" Property="Opacity" Value="0.5"/>
            </Trigger>

            <Trigger Property="IsChecked" Value="True">
                <!--<Setter TargetName="label" Property="Border.Background" Value="{StaticResource AlertBackgroundBrush}"/>
                                    <Setter TargetName="label" Property="Border.BorderBrush" Value="{StaticResource AlertBrush}"/>
                                    <Setter TargetName="PrimaryContent" Property="TextBlock.Foreground" Value="{StaticResource AlertBrush}"/>-->
            </Trigger>

        </ControlTemplate.Triggers>

    </ControlTemplate>

    <Style x:Key="Toolbar_MenuItemStyle" TargetType="MenuItem">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="MenuItem">
                    <Setter Property="Template" Value="{StaticResource ToolBarMenu_SubmenuItem}"/>
                </Style>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Role" Value="TopLevelHeader">
                <Setter Property="Template" Value="{StaticResource ToolBarMenu_TopLevelHeader}"/>
                <Setter Property="Grid.IsSharedSizeScope" Value="true"/>
            </Trigger>
            <Trigger Property="Role" Value="TopLevelItem">
                <Setter Property="Template" Value="{StaticResource ToolBarMenu_TopLevelItem}"/>
            </Trigger>
            <Trigger Property="Role" Value="SubmenuHeader">
                <Setter Property="Template" Value="{StaticResource ToolBarMenu_SubmenuItem}"/>
            </Trigger>
            <Trigger Property="Role" Value="SubmenuItem">
                <Setter Property="Template" Value="{StaticResource ToolBarMenu_TopLevelItem}"/>
            </Trigger>
        </Style.Triggers>
    </Style>



</ResourceDictionary>